﻿using System;
using System.Diagnostics;
namespace TimHeuer.Expression.S3Publish.S3Model
{
    [DebuggerDisplay("{Name}")]
    public class S3Bucket : IEquatable<S3Bucket>, IComparable<S3Bucket>, IComparable
    {
        public S3Bucket()
        {
        }

        public S3Bucket(string name)
        {
            _name = name;
        }

        private string _name = String.Empty;

        public string Name
        {
            [DebuggerStepThrough]
            get { return _name; }
            [DebuggerStepThrough]
            set { _name = value; }
        }

        public override int GetHashCode()
        {
            return _name.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as S3Bucket);
        }

        #region IEquatable<S3Bucket> Members

        public bool Equals(S3Bucket other)
        {
            return ((other != null) && (other._name.Equals(_name)));
        }

        #endregion

        #region IComparable<S3Bucket> Members

        public int CompareTo(S3Bucket other)
        {
            if (other != null)
            {
                return String.Compare(other.Name, Name, true);
            }
            else
            {
                // A non-null object is "greater" than a null one.
                // Barely. :)
                return 1;
            }
        }

        #endregion

        #region IComparable Members

        public int CompareTo(object obj)
        {
            return CompareTo(obj as S3Bucket);
        }

        #endregion
    }
}
